package com.quantice.RowList;

import java.util.ArrayList;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.quantice.mainActivity.R;

public class RowListAdapter extends ArrayAdapter<RowList> {

	private LayoutInflater layoutInflater;
	private int layoutResourceId;
	private ArrayList<RowList> data;

	public RowListAdapter(LayoutInflater layoutInflater, int layoutResourceId,
			ArrayList<RowList> data) {
		super(layoutInflater.getContext(), layoutResourceId, data);
		this.layoutResourceId = layoutResourceId;
		this.layoutInflater = layoutInflater;
		this.data = data;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		RowListHolder holder = null;
		if (row == null) {
			row = this.layoutInflater.inflate(layoutResourceId, parent, false);
			holder = new RowListHolder();
			holder.textDate = (TextView) row.findViewById(R.id.itemdate);
			holder.textMoney = (TextView) row.findViewById(R.id.itemmoney);

			row.setTag(holder);
		} else {
			holder = (RowListHolder) row.getTag();
		}

		RowList rowList = data.get(position);
		holder.textMoney.setText(rowList.getDate());
		holder.textDate.setText(rowList.getMoney());

		return row;
	}

	static class RowListHolder {
		TextView textDate;
		TextView textMoney;
	}
}